package zhuyun.code.launcheractivity.view

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.provider.SyncStateContract
import kotlinx.android.synthetic.main.activity_my_home_page.*
import zhuyun.code.launcheractivity.R
import zhuyun.code.launcheractivity.model.Constants
import zhuyun.code.launcheractivity.model.NetworkRequest
import zhuyun.code.launcheractivity.model.ResponseDataHandler
import zhuyun.code.launcheractivity.model.data.BaseResponse
import zhuyun.code.launcheractivity.model.data.GetDetailByUserIdBean
import zhuyun.code.launcheractivity.utils.GlideUtil
import zhuyun.code.launcheractivity.view.fragment.HomepageFriendFragment

class MyHomePageActivity : BaseActivity() {
    private lateinit var friendId:String

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_my_home_page)
        friendId = intent.getStringExtra(Constants.USER_ID)!!
        val args = Bundle()
        args.putString(Constants.USER_ID,friendId)
        val homepageFriendFragment = HomepageFriendFragment()
        homepageFriendFragment.arguments = args
        showFragment(R.id.container,homepageFriendFragment)
        getData()
    }

    private fun getData(){
        NetworkRequest.getDetailByUserId(friendId,object :ResponseDataHandler<GetDetailByUserIdBean>(){
            override fun onSuccess(
                resultData: GetDetailByUserIdBean?,
                baseResponse: BaseResponse<GetDetailByUserIdBean>
            ) {
                resultData?.let {
                    GlideUtil.displayEspImage(resultData.HeadUrl,iv_head,R.drawable.pic_touxiang_normal)
                    tv_name.text = resultData.NickName
                    tv_profile.text = resultData.UserAbstract

                }
            }

            override fun onFailure(errMsg: String?) {

            }

        })
    }

}
